package com.shortvedio.search.api;

import com.shortvedio.base.context.BaseContext;
import com.shortvedio.base.model.Result;
import com.shortvedio.search.service.ClassifyService;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@RestController
public class LabelController {

    @Autowired
    private ClassifyService classifyService;

    @GetMapping("get_label")  //搜索分类
    public Result getLabel(@RequestParam String keyWord){
        Result label = null;
        try {
            label = classifyService.getLabel(keyWord);
        } catch (IOException e) {
            return Result.error("搜索异常");
        }
        return label;
    }

    @GetMapping("get_classify")  //获取指定类型的分类
    public Result getClassify(@RequestParam Integer type){
        Result classifyList = classifyService.getClassifyList(type);
        return classifyList;
    }

    @GetMapping("get_user_add_interest")//得到用的感兴趣列表
    public Result getUserAddInterest(){
        Long currentId = BaseContext.getCurrentId();
        Result userAddInterest = classifyService.getUserAddInterest(currentId);
        return userAddInterest;
    }

}
